const data = [
    {
        src: './img/focus1.jpg',
        text: '周杰伦'
    },
    {
        src: './img/focus2.jpg',
        text: 'G.E.M. 邓紫棋'
    },
    {
        src: './img/focus3.jpg',
        text: '林俊杰'
    },
    {
        src: './img/focus4.jpg',
        text: '薛之谦'
    },
    {
        src: './img/focus5.jpg',
        text: '陈奕迅'
    },
    {
        src: './img/focus6.jpg',
        text: '告五人'
    },
    {
        src: './img/focus7.jpg',
        text: '时代少年团'
    },
    {
        src: './img/focus8.jpg',
        text: '王靖雯'
    },
    {
        src: './img/focus9.jpg',
        text: '蔡健雅'
    },
    {
        src: './img/focus10.jpg',
        text: '王源'
    },
    {
        src: './img/focus11.jpg',
        text: '蜡笔小新'
    }
]
const surname = ['郝','郁','李','代','宋','曹','刘','杨','仝']
const names = ['云奇','普','峰','志贤','一鸣','世辉','坤','善源','闯']
function rendom(min,max) {
    return Math.floor(Math.random() * (max - min)) + min;
}
const texts = document.querySelectorAll('.content-text-list')
const search = document.querySelector('.search')
const list = document.querySelectorAll('.content-list')
// 点击切换图片文字
search.addEventListener('click',function(e){
    if (e.target.tagName === 'A') {
        for (let i =0;i<list.length;i++) {
            let val = rendom(0,data.length)
            list[i].innerHTML =  
            `<a>
                <img src="${data[val].src}">
            </a>
            <a>
                ${data[val].text}
            </a>`
        }
        getText()
    }
       
})


function getText() {
    
    for(let j = 0;j<texts.length;j++){
        texts[j].innerHTML = ''
        for (let k = 0; k< 25; k++) {
            texts[j].innerHTML += `
            <a href="#">${surname[rendom(0,surname.length)]}${names[rendom(0,names.length)]}</a>
            `
        }
    }
}

getText()
